<!DOCTYPE html>
<html lang="zh-cn">
   <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>{$CONF['mallTitle']}后台管理中心</title>
      <link href="__PUBLIC__/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <link href="__ROOT__/Apps/Admin/View/css/AdminLTE.css" rel="stylesheet" type="text/css" />
      <!--[if lt IE 9]>
      <script src="__PUBLIC__/js/html5shiv.min.js"></script>
      <script src="__PUBLIC__/js/respond.min.js"></script>
      <![endif]-->
      <script src="__PUBLIC__/js/jquery.min.js"></script>
      <script src="__PUBLIC__/plugins/bootstrap/js/bootstrap.min.js"></script>
      <script src="__PUBLIC__/js/common.js"></script>
      <script src="__PUBLIC__/plugins/plugins/plugins.js"></script>
      <script src="__PUBLIC__/plugins/kindeditor/kindeditor.js"></script>
      <script src="__PUBLIC__/plugins/kindeditor/lang/zh_CN.js"></script>
   </head>
   <style>
    .mxc-tab-box{width:100%; height:auto; margin:0px auto;}
	.mxc-tab-nav{margin:0; padding:0; height:25px; line-height:24px;position: relative;top:2px;left:3px;}
	.mxc-tab-nav li{cursor:pointer;float:left; margin:0 0px; list-style:none; border:1px solid #ddd; border-bottom:none; height:24px; width:100px; text-align:center; background:#eeeeee;color:#000000;}
	.mxc-tab-nav .on{background:#ffffff;color:#000000;border-bottom:0 none;}
	.mxc-tab-content{padding:5px;width:99%; height:auto; border:1px solid #ddd;background:#FFF;}
    .mxc-gallery-imgs{width:770px;height:auto;}
    .mxc-gallery-img{width:140px;height:100px;float:left;overflow:hidden;margin:10px 5px 5px 5px;}
   </style>
   <script>
   $(function () {
	   $('#tab').TabPanel({tab:0});
	   KindEditor.ready(function(K) {
			editor1 = K.create('textarea[name="goodsDesc"]', {
				height:'250px',
				allowFileManager : false,
				allowImageUpload : true,
				items:[
				        'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
				        'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
				        'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
				        'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
				        'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
				        'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|','image','table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
				        'anchor', 'link', 'unlink', '|', 'about'
				],
				afterBlur: function(){ this.sync(); }
			});
		});

   });
   
   
   function changeStatus(id,v){
	   Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
	   $.post("{:U('Admin/Goods/changeGoodsStatus')}",{id:id,status:v},function(data,textStatus){
				var json = MXC.toJson(data);
				if(json.status=='1'){
					Plugins.setWaitTipsMsg({ content:'操作成功',timeout:1000,callback:function(){
						location.href="{:U('Admin/Goods/index')}";
					}});
				}else{
					Plugins.closeWindow();
					Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
				
				}
	   });
   }
   </script>
   <body class="mxc-page">
       <form name="myform" method="post" id="myform" action="{:U('Admin/Goods/toAddGoods')}" enctype="multipart/form-data" >
       <div id='tab' class="mxc-tab-box">
		<ul class="mxc-tab-nav">
	    	<li>商品信息</li>
	        
	    </ul>
    	<div class="mxc-tab-content" style='width:98%;'>
    	<div class='mxc-tab-item'>
	        <table class="table table-hover table-striped table-bordered mxc-form">
	        	 

	           <tr>
	             <th width='120'>店铺名铺<font color='red'>*</font>：</th>
	             <td>
					<select name="shopId">
						 <option value="0">0.&nbsp;后台特殊店铺</option>
                         <foreach name="Shoplist" item="v" key="k">
                            <option value="{$v.shopId}" <if condition="$v['shopId'] === $goods['shopId'] or $v['shopId']==1" >selected</if>  >{$v['shopId']}.&nbsp;{$v.shopName}</option>
                         </foreach>
                     </select>
	             </td>
	           </tr>

	           <tr>
	             <th width='120'>商品名称<font color='red'>*</font>：</th>
	             <td><input type="text" name="goodsName" value="{$goods.goodsName}" ></td>
	           </tr>
	           <tr>
	             <th width='120'>商品编码<font color='red'>*</font>：</th>
	             <td><input type="text" goodsId="{$goods.goodsId}" name="goodsSN" value="{$goodsSn?$goodsSn:$goods.goodsSn}" /><!-- 要求前2位是sn，后面可以自行输入并且在数据表内是唯一的 --></td>
	           </tr>
	            <tr>
	             <th width='120'>售价<font color='red'>*</font>：</th>
	             <td><input name="marketPrice" type="text" value="{$goods.marketPrice}"/></td>
	           </tr>
	            <tr>
	             <th width='120'>合作价<font color='red'>*</font>：</th>
	             <td><input type="text" name="shopPrice" value="{$goods.shopPrice}" /></td>
	           </tr>
	            <tr>
	             <th width='120'>商品库存<font color='red'>*</font>：</th>
	             <td><input type="text" name="goodsStock" value="{$goods.goodsStock}" ></td>
	           </tr>
	            <tr>
	             <th width='120'>尺寸<font color='red'>*</font>：</th>
	             <td><input type="text" name="goodsSize" value="{$goods.goodsSize}" ></td>
	           </tr>
               <tr>
	             <th width='120'>重量<font color='red'>*</font>：</th>
	             <td><input type="text" name="goodsWeight" value="{$goods.goodsWeight}" ></td>
	           </tr>
	           <tr>
	             <th width='120'>商品状态<font color='red'>*</font>：</th>
	             <td colspan='3'>
					 <select name="isSale" id="isSale">
						 <option value="1" <if condition="$goods['isSale']==1">selected</if> >上架</option>
						 <option value="0" <if condition="$goods['isSale']==0">selected</if> >下架</option>
					 </select> 
	             </td>
	           </tr>
	          <tr>
	             <th width='120'>商品款式<font color='red'>*</font>：</th>
	             <td colspan='3'>
					 <select name="catId">
                         <foreach name="catslist" item="v">
                         	<optgroup label="{$v.catName}">
                         		<foreach name="v.child" item="v2">
                             		<option value="{$v2.catId}" <if condition="$goods['goodsCatId2']==$v2['catId']">selected</if> >{$v2.catName}</option>
                         		</foreach>
                         	 </optgroup>
                         </foreach>
                     </select>
				 </td>
	           </tr>
	           <tr>
	             <th width='120'>商品种质<font color='red'>*</font>：</th>
	             <td colspan='3'>
					 <select name="classId">
                         <foreach name="classlist" item="v">
                         	<optgroup label="{$v.className}">
                         		<foreach name="v.child" item="v2">
                             		<option value="{$v2.classId}" <if condition="$goods['goodsClassId2']==$v2['classId']">selected</if> >{$v2.className}</option>
                         		</foreach>
                         	 </optgroup>
                         </foreach>
                     </select>
                 </td>
	           </tr>
	           <tr>
	             <th width='120'>商品内容<font color='red'>*</font>：</th>
	             <td colspan='3'>
					 <textarea name="goodsContent"   cols="30" rows="10">{$goods.goodsContent}</textarea>
	             </td>
	           </tr>
				<tr>
	             <th width='120'>商品封面图片<font color='red'>*</font>：</th>
	             <td colspan='3'>
	            	<if condition="$goods['goodsImg']">
	      				<img src="/{$goods.goodsImg}" style=" width: 100px">
	      			</if>
						<input type="file" name="goodsFaceImg" value="" />
	             </td>
	           </tr>

	           	<tr>
	             <th width='120'>商品图片<font color='red'>*</font>：</th>
	             <td colspan='3'>
	              
	             	<foreach name="galleryList" item="img">
	             		<dd>
	             		<img src="/{$img.goodsImg}" style=" width: 100px"/>
	             		<span galleryId="{$img.id}" class="galleryImg">删除</span>
	             		</dd>
	             	</foreach>
	             	 
					 <input type="file" name="goodsImg[]" value="" />
					 <input type="file" name="goodsImg[]" value="" />
					 <input type="file" name="goodsImg[]" value="" />
					 <input type="file" name="goodsImg[]" value="" />
					 <input type="file" name="goodsImg[]" value="" />
					 <input type="file" name="goodsImg[]" value="" />
					 <input type="file" name="goodsImg[]" value="" />
					 <input type="file" name="goodsImg[]" value="" />
	             </td>
	           </tr>

	           <tr>
	             <td colspan='3' style='padding-left:250px;'>
	             	<if condition="$goods.goodsId">
	                	<input type="hidden" name="goodsId" value="{$goods.goodsId}" />
	                <button type="submit" class="btn btn-primary" >提&nbsp;交</button>
	                <else/>
						<button type="submit" class="btn btn-primary" >新&nbsp;增</button>
	                </if>
	             </td>
	           </tr>

	        </table>
	      </div>
	      <div class='mxc-tab-item'>
	        
	      	 <div style='clear:both;'></div>
	      </div>
       </div>
       </div>
       		<input type="hidden" name="nextpage" value="{$nextpage}" />
       </form>
   </body>
   <script>
   $(".galleryImg").on("click",function(){
 
   		_galleryid = $(this).attr('galleryid');
   		_self = $(this);
   		$.get("{:U('/Admin/Goods/galleryDele')}?gid="+_galleryid,function(_res) {
  			if (_res=='success') {
  				_self.parents("dd").remove();
  			}
   		})
   })


   $("input[name='goodsSN']").on("blur",function(){

   		$.get("{:U('/Admin/Goods/querySn')}?goodsId="+$(this).attr('goodsId')+"&sn="+$(this).val(),function(_res) {
			
  			if (_res=='occupation') {
  				 alert('商品编码被占用！');
  				 return false;
  			}
   		})
   })
   </script>

</html>